package com.leetcode.partition6;

import java.io.*;

/**
 * @author `RKC`
 * @date 2021/12/31 9:32
 */
public class LC507完美数 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        int[] nums = new int[s.length];
        for (int i = 0; i < s.length; i++) nums[i] = Integer.parseInt(s[0]);
        for (int i = 0; i < nums.length; i++) {
            writer.write(checkPerfectNumber(nums[i]) + "\n");
        }
        writer.flush();
    }

    public static boolean checkPerfectNumber(int num) {
        if (num == 1) return false;
        int sum = 0;
        for (int i = 1; i <= num / i; i++) {
            if (num % i == 0) {
                sum += i;
                if (i != num / i && num / i != num) sum += num / i;
            }
        }
        return sum == num;
    }
}
